package com.course.service.impl;

import com.course.entity.ResultBody;
import com.course.mapper.GradeMapper;
import com.course.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class GradeServiceImpl implements GradeService {
    @Autowired
    private GradeMapper gradeMapper;
    @Override
    public ResultBody addgrade(Map<String,Object> map) {
        if(gradeMapper.addgrade(map)>0)
        {
            return new ResultBody(200,"添加成功",true);
        }
       else
           return new ResultBody(500,"添加失败",false);
    }
    @Override
    public ResultBody displaygrade()
    {
        if(gradeMapper.displaygrade()!=null)
        return new ResultBody(200,"查询成功",gradeMapper.displaygrade(),gradeMapper.displaygrade().size());
        else if(gradeMapper.displaygrade()==null)
        {
            return new ResultBody(200,"暂无相关内容",false);
        }
        else
            return new ResultBody(500,"查询失败",false);
    }
    @Override
    public ResultBody delgrade(Map<String,Object> map)
    {
        if(gradeMapper.delgrade(map)>0)
        {
            return new ResultBody(200,"删除成功",true);
        }
        else
            return new ResultBody(500,"删除失败",false);
    }
    @Override
    public ResultBody updategrade(Map<String,Object> map)
    {
        if(gradeMapper.updategrade(map)>0)
        {
            return new ResultBody(200,"更新成功",true);
        }
        else
            return new ResultBody(500,"更新失败",false);
    }
}
